package org.speed.jdk;

import java.util.ArrayList;

public class HashCode {
	
	public static void main(String[] args) {
		ArrayList list = new ArrayList();
		int numberExist=0;
		
		//证明hashcode的值不是内存地址
	    for (int i = 0; i < 10000; i++) {
	        Object obj=new Object();
	        if (list.contains(obj.toString())) {
	            System.out.println(obj.toString() +"  exists in the list. "+ i);
	            numberExist++;
	        }
	        else {
	            list.add(obj.toString());
	        }
	    }
		
	    System.out.println("repetition number:"+numberExist);
	    System.out.println("list size:"+list.size());

		
	}

}
